<template>
 <div class="credit">

        <el-row type="flex" class="row-bg" justify="center">
           <el-form ref="formData3" :inline="true" :model="formData3" status-icon label-position="right" label-width="160px" style=" margin-left:50px;">
          
          <el-col :span="40" 
            v-for="(item,index) in formData3.powerAttrList"
            :key="item.key"  
          >
            <div class="grid-content bg-purple-light">
                  <h3 style="font-weight:400;font-size:16px;">{{ item.clientType==1 ? "借款人" : "共借人"}}（{{item.borrowerName}}）征信编辑栏</h3>
                 
                  <!-- <el-form-item label="逾期次数" prop="overdueNumber">
                    <el-input type="number"  v-model="dataForm.overdueNumber" placeholder="请输入逾期次数"/>
                  </el-form-item>                  -->
                   <el-form-item label="贷款总额度" :prop="'powerAttrList.' + index + '.loanTotalAmount'">
                    <el-input type="number" v-model="item.loanTotalAmount" placeholder="请输入贷款总额度"><template slot="append">万</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="当前逾期金额"  :prop="'powerAttrList.' + index + '.loanAmount'">
                    <el-input type="number" v-model="item.loanAmount" placeholder="请输入当前逾期金额"><template slot="append">万</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="贷款剩余额度" :prop="'powerAttrList.' + index + '.loanRemainAmount'">
                    <el-input type="number" v-model="item.loanRemainAmount" placeholder="请输入贷款剩余额度"><template slot="append">万</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="查询次数" :prop="'powerAttrList.' + index + '.queryNumber'">
                    <el-input type="number" v-model="item.queryNumber" placeholder="请输入查询次数"><template slot="append">次</template></el-input>
                  </el-form-item>                 
                   <!-- <el-form-item label="近六个月总使用额度" prop="nearlySixUseAmount" class="item_margin">
                    <el-input type="number"  v-model="dataForm.nearlySixUseAmount" placeholder="请输入近六个月总使用额度"/>
                  </el-form-item>                   -->
                   <el-form-item label="2年内贷款逾期次数" :prop="'powerAttrList.' + index + '.loadOverdueNumber'">
                    <el-input type="number"  v-model="item.loadOverdueNumber" placeholder="请输入2年内贷款逾期次数"><template slot="append">次</template></el-input>
                  </el-form-item>                  
                   <el-form-item label="2年内贷记卡逾期次数" :prop="'powerAttrList.' + index + '.creditCardOverdueNumber'">
                    <el-input type="number"  v-model="item.creditCardOverdueNumber" placeholder="请输入2年内贷记卡逾期次数"><template slot="append">次</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="信用卡授信总额度" :prop="'powerAttrList.' + index + '.creditTotalAmount'">
                    <el-input type="number" v-model="item.creditTotalAmount" placeholder="请输入信用卡授信总额度"><template slot="append">万</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="近六个月月平均还款额" :prop="'powerAttrList.' + index + '.nearlySixRepaymentAmount'">
                    <el-input type="number" v-model="item.nearlySixRepaymentAmount" placeholder="近六个月月平均还款额"><template slot="append">万</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="信用卡已使用总额度" :prop="'powerAttrList.' + index + '.creditUseAmount'">
                    <el-input type="number" v-model="item.creditUseAmount" placeholder="请输入信用卡已使用总额度"><template slot="append">万</template></el-input>
                  </el-form-item>                 
                   <el-form-item label="异常情况说明" :prop="'powerAttrList.' + index + '.abnormalSituation'">
                    <el-input type="textarea"  v-model="item.abnormalSituation" placeholder="请输入异常情况说明"/>
                  </el-form-item>
              
          
            </div>
            </el-col>
         
          <el-col :span="15">
            <div class="grid-content bg-purple-light">
                  <h3 style="font-weight:400;font-size:16px;">大数据核对栏</h3>
                 
                  <el-form-item label="同盾网" prop="name">
                   <el-button @click="targetUrl('https://credit.tongdun.cn/creditbodyguard/bodyguard/manualInputHistory.htm')">跳转链接</el-button>
                  </el-form-item>
                 
                  <el-form-item label="风险预警网" prop="name">
                   <el-button @click="targetUrl('https://www.fengxian110.com')">跳转链接</el-button>
                  </el-form-item>
                 
                  <el-form-item label="企查查" prop="name">
                   <el-button @click="targetUrl('https://www.qcc.com/?utm_source=baidu&utm_medium=cpc&utm_term=查查企')">跳转链接</el-button>
                  </el-form-item>
                 
                  <el-form-item label="全国执行信息公开网" prop="name">
                   <el-button @click="targetUrl('http://zxgk.court.gov.cn/zhixing/')">跳转链接</el-button>
                  </el-form-item>
                 
                  <el-form-item label="裁判文书网" prop="name">
                   <el-button @click="targetUrl('https://wenshu.court.gov.cn/')">跳转链接</el-button>
                  </el-form-item>
                 
                 
                 
            </div>
            </el-col>
            </el-form>
           <!-- v-if="operationLook === undefined" -->
        </el-row>
          <div style="width:400px;margin-top:5%;margin-left:30%;"  >
              <!-- <el-button  type="primary" @click="resetForm" style="width:150px;height:40px;">清空</el-button> -->
              <el-button v-if="operationLook === undefined" v-permission="'system:credit:edit'" type="warning" @click="createData" style="width:150px;height:40px;">保存</el-button>
          </div>
   
  </div>
</template>


<script>
import ProjectApprovalHistory from '@/views/task/task_detail/project_approval_history';
import { findByProjectId,addCredit } from '@/api/credit'
export default {
  name: 'add',
  components: {
     ProjectApprovalHistory,
     },
    props:{
      projectId: undefined,
      taskId: undefined,
      operationLook: undefined
    },
  data() {
    return {
      activeIndex: '1',
      name: "11",
      dataForm: {
        projectId:undefined,
        borrowerId: undefined,
        clientType: undefined,
        overdueNumber:undefined,
        loanTotalAmount:undefined,
        loanAmount:undefined,
        loanRemainAmount:undefined,
        queryNumber:undefined,
        nearlySixUseAmount:undefined,
        nearlySixRepaymentAmount:undefined,
        creditTotalAmount:undefined,
        creditUseAmount:undefined,
        abnormalSituation:undefined,
      },
      formData3: {
        powerAttrList: [
          {
            realName: "",
            relation: "",
            mobile: "",
          },
          {
            realName: "",
            relation: "",
            mobile: "",
          },
          {
            realName: "",
            relation: "",
            mobile: "",
          },
        ]
      },
    }
  },
  computed: {
   
  },
  created() {
    console.log(this.taskId)
    this.findByProjectId()
  },
  methods: {
    findByProjectId() {
      findByProjectId({projectId:this.projectId})
        .then(response => {
          if(response.data != undefined ) {
            this.formData3.powerAttrList = response.data
            for( let i = 0; this.formData3.powerAttrList.length; i++ ) {
            this.formData3.powerAttrList[i].taskId = this.taskId
        }
          }
        })
        .catch(() => {
        })
    },
     targetUrl(url){
       window.open(url)
    },
    stepChange(currentStep){
        this.currentStep = currentStep;
    },
    handleSelect(val){
      this.activeIndex = val
    },
      createData(){

        addCredit(this.formData3.powerAttrList)
            .then(response => {
              this.findByProjectId()
              this.$notify.success({
                title: '成功',
                message: '保存成功'
              })
            })
            .catch(response => {
            })
    },
    resetForm(){
      this.dataForm = {
        projectId:this.projectId,
        overdueNumber:0,
        loanTotalAmount:0,
        loanAmount:0,
        loanRemainAmount:0,
        queryNumber:0,
        nearlySixUseAmount:0,
        nearlySixRepaymentAmount:0,
        creditTotalAmount:0,
        creditUseAmount:0,
        abnormalSituation:'',
      }
    }
  }
}
</script>

<style scoped>

.item_margin{
  /* margin-left: 260px; */
}

</style>

